

#setwd("~/Dropbox/Job Market Paper/IO Revisions/Replication_Files/Replication_Appendix/A_Fig_8_9")





data_q<-read.csv(file="data_fig_A8_9.csv")



brea<-lm(logArea~as.factor(Year)-1,data=data_q)




diff<-matrix(NA,length(coef(brea)),length(coef(brea)))

tstat<-diff


for(i in 1:length(coef(brea))){
	
	for(j in 1:length(coef(brea))){
		
		diff[i,j]<-coef(brea)[i]-coef(brea)[j]
		
		
		if(j >= i) { diff[i,j]<-0  }
		
		tstat[i,j]<-diff[i,j]/sqrt(vcov(brea)[i,i]+vcov(brea)[j,j]-vcov(brea)[i,j])
		
		
		
		
	}
}


color<-ifelse(abs(tstat)> 1.96,"red","black")






############################################################################################



diff2<-ifelse(diff==0,NA,diff)


pdf(file="Figure_A8.pdf")

plot(1:length(coef(brea)),1:length(coef(brea)),type="n", main="Difference in Time Effect", xlab="Year",ylab="Year", axes=F)


for(i in 1:length(coef(brea))){
	
	for(j in 1:length(coef(brea))){
		text(i,j,round(abs(diff2[i,j]),3), col=color[i,j],cex=.25)		
		
		
		}
}

axis(1, at=seq(1,160,by=20), labels=seq(1100,1800,by=100))
axis(2, at=seq(1,160,by=20), labels=seq(1100,1800,by=100))

abline(h=80,lty=2)



abline(v=80,lty=2)


dev.off()


##############################  Figure  9 #######################################################



data_q$resid<-resid(brea)


sd<-tapply(data_q$resid,data_q$Year,sd)




plot(sd)
plot(sd^2)
mean<-tapply(data_q$resid,data_q$Year,mean)
plot(mean)


pdf(file="Figure A9.pdf")



boxplot(data_q$resid~data_q$Year,plot=T,ylab=expression(hat(epsilon)))


dev.off()


